package chapter02.d02;
/*
 * synchronized没起作用
 * 
 */

public class Demo2 {
	public static void main(String[] args) {
		for (int i = 0; i < 3; i++) {
			Thread thread = new MyThread2();
			thread.start();
		}
	}

}

class Test2 {
	public void test() {
		synchronized (this) {
			System.out.println("test开始..");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println("test结束..");
		}

	}
}

class MyThread2 extends Thread {

	public void run() {
		Test2 t = new Test2();
		t.test();
	}
}
